<template>
  <div class="hot-goods pad-20" v-if="salesGoodsRankList && salesGoodsRankList.length > 0">
    <h2>店铺商品销售排行</h2>
    <div class="goods-list mar-r--20 mar-b--5 mar-t-15">
      <div v-for="(item, index) in salesGoodsRankList" :key="index"
        class="goods-bar mar-r-28 mar-b-8 cursor-p" @click="goodsEls(item)">
        <img :src="item.imageUrl" alt="" class="goods-img">
        <div class="goods-info">
          <div class="flex flex-between">
            <div class="_line-1">{{item.title}}</div>
          </div>
          <div class="flex flex-between v-align-c pad-t-6">
            <div class="price font-price font-16 font-w">￥{{item.distributePrice || '0.00'}}</div>
            <div class="font-14 font-color-6">已售{{item.totalSalesNum}}件</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
  import {
    defineComponent,
    ref,
    onMounted,
    inject
  } from 'vue'
  import {
    useRouter
  } from 'vue-router'
  import {
    jumpPage
  } from '@/utils/jumpPageUtils'
  export default defineComponent({
    name: 'GoodsHot',
    setup() {
      const router = useRouter()
      let salesGoodsRankList = inject('salesGoodsRankList')
      
      onMounted(() => {})
      
      const goodsEls = (item: any) => {
        jumpPage(router, 1, 1, 2001, '?goodsId=' + item.goodsId, 1)
      }
      
      return {
        salesGoodsRankList,
        goodsEls
      }
    }
  })
</script>

<style lang="scss" scoped>
  $darkBlue: #182245;
  $recommendGoodsWidth: 190px;

  .hot-goods {
    h2 {
      margin: -4px 0 0 0;
      padding: 0;
      font-weight: normal;
      font-size: 20px;
    }

    .goods-list {
      .goods-bar {
        width: $recommendGoodsWidth;
      }

      .goods-img {
        width: $recommendGoodsWidth;
        height: 190px;
      }

      .goods-info {
        width: $recommendGoodsWidth;
        // height: 142px;
        padding: 8px 0 8px 0;
        box-sizing: border-box;
      }

      ._line-1 {
        /* line-height: 1.4; */
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        word-break: break-word;
      }

      ._line-2 {
        /* line-height: 1.4; */
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        word-break: break-word;
      }
    }
  }
</style>
